<template>
  <base-breadcrumb>
    <iframe ref="iframe" :src="reportIntegrationUrl" height="100%" width="100%" scrolling="no" frameborder="0"></iframe>
  </base-breadcrumb>
</template>

<script>
import Vue from 'vue'
export default {
  name: "ReportIntegration",
  data() {
    return {
      reportIntegrationUrl: null,
      token: Vue.getAcloudProvider().getAccessToken(),
    }
  },
  watch: { '$route': 'getUrl' },
  created() {
    this.$nextTick(() => {
      this.getUrl();
      this.setWinHeight(this.$refs.iframe)
    })
  },
  methods: {
    //获取请求地址
    getUrl() {
      let _query = this.$route.query;
      let userInfo = JSON.parse(sessionStorage.getItem('ycloud-user_info'))
      if (Object.keys(_query).length && _query.path) {
        let _url = process.env.VUE_APP_REPORT_INTEGRATION;
        this.reportIntegrationUrl = `${_url}${_query.path.split(_query.moduleName)[1]}&code=${this.token}&id=${userInfo.currentPost.id}`
      }
    },
    //设置iframe高度
    setWinHeight: function (obj) {
      var win = obj;
      if (document.getElementById) {
        if (win && !window.opera) {
          if (win.contentDocument && win.contentDocument.body.offsetHeight) {
            if (win.contentDocument.body.offsetHeight < 420) {
              win.height = 420;//设置最小高度
            } else {
              win.height = win.contentDocument.body.offsetHeight;
            }
          }
          else if (win.Document && win.Document.body.scrollHeight)
            win.height = win.Document.body.scrollHeight;
        }
      }
    }
  }
}
</script>

<style>

</style>